package cn.com.shopec.erp.financing.commo;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.stereotype.Component;

import cn.com.shopec.erp.common.constant.SZSCMConstant;
import cn.com.shopec.erp.common.utils.DateUtil;
import cn.com.shopec.erp.common.utils.RandomUtil;
import cn.com.shopec.erp.financing.entity.FreightSettlement;
import cn.com.shopec.erp.financing.entity.FreightSettlementDetail;
import cn.com.shopec.erp.financing.vo.FreightSettlementDetailVo;
import cn.com.shopec.erp.financing.vo.FreightSettlementVo;

/**
 * @ClassName: FreightSettlementPropertyUtils
 * @Description: 运费结算单实体表与虚拟表互换
 * @author: gaoyaxiong
 * @date: 2013-5-27 下午13:47:13
 */
@Component
public class FreightSettlementPropertyUtils {

	/**
	 * @methodName： getFreightSettlement
	 * @Description: 运费结算单虚拟表转实体表
	 * @param FreightSettlementVo
	 * @return FreightSettlement
	 * @author: gaoyaxiong
	 * @date: 2013-5-27 下午13:22:03
	 */
	public FreightSettlement getFreightSettlement(FreightSettlementVo fsVo) {
		FreightSettlement fs = new FreightSettlement();
		fs.setId(fsVo.getId());
		fs.setStatementNo(fsVo.getStatementNo());
		fs.setLogisticsNo(fsVo.getLogisticsNo());
		fs.setLogisticsName(fsVo.getLogisticsName());
		fs.setStartDate(fsVo.getStartDate());
		fs.setEndDate(fsVo.getEndDate());
		fs.setStatementTotal(fsVo.getStatementTotal());
		fs.setCreateTime(fsVo.getCreateTime());
		fs.setCheckState(fsVo.getCheckState());
		fs.setCheckName(fsVo.getCheckName());
		fs.setCheckTime(fsVo.getCheckTime());
		fs.setStatementState(fsVo.getStatementState());
		fs.setStatementTime(fsVo.getStatementTime());
		fs.setStatementName(fsVo.getStatementName());
		fs.setDeleteFlag(fsVo.getDeleteFlag());
		return fs;
	}

	/**
	 * @methodName： getFreightSettlementVo
	 * @Description: 运费结算单实体表转虚拟表
	 * @param FreightSettlement
	 * @return FreightSettlementVo
	 * @author: gaoyaxiong
	 * @date: 2013-5-27 下午13:22:03
	 */
	public FreightSettlementVo getFreightSettlementVo(FreightSettlement fs) {
		FreightSettlementVo fsVo = new FreightSettlementVo();
		fsVo.setId(fs.getId());
		fsVo.setStatementNo(fs.getStatementNo());
		fsVo.setLogisticsNo(fs.getLogisticsNo());
		fsVo.setLogisticsName(fs.getLogisticsName());
		fsVo.setStartDate(fs.getStartDate());
		fsVo.setEndDate(fs.getEndDate());
		fsVo.setStatementTotal(fs.getStatementTotal());
		fsVo.setCreateTime(fs.getCreateTime());
		fsVo.setCheckState(fs.getCheckState());
		fsVo.setCheckName(fs.getCheckName());
		fsVo.setCheckTime(fs.getCheckTime());
		fsVo.setStatementState(fs.getStatementState());
		fsVo.setStatementTime(fs.getStatementTime());
		fsVo.setStatementName(fs.getStatementName());
		fsVo.setDeleteFlag(fs.getDeleteFlag());
		fsVo.setActTotal(fs.getActTotal());
		return fsVo;
	}

	/**
	 * @methodName： getFsDetailVo
	 * @Description: 运费结算明细单虚拟表转实体表
	 * @param FreightSettlementDetail
	 * @return FreightSettlementDetailVo
	 * @author: gaoyaxiong
	 * @date: 2013-5-27 下午13:22:03
	 */
	public FreightSettlementDetailVo getFsDetailVo(
			FreightSettlementDetail fsDetail) {
		FreightSettlementDetailVo fsDetailVo = new FreightSettlementDetailVo();
		fsDetailVo.setId(fsDetail.getId());
		fsDetailVo.setStatementNo(fsDetail.getStatementNo());
		fsDetailVo.setExpressNo(fsDetail.getExpressNo());
		fsDetailVo.setOrderNo(fsDetail.getOrderNo());
		fsDetailVo.setSendAddress(fsDetail.getSendAddress());
		fsDetailVo.setProductWeight(fsDetail.getProductWeight());
		fsDetailVo.setLogisticsExpenses(fsDetail.getLogisticsExpenses());
		fsDetailVo.setSendDate(fsDetail.getSendDate());
		fsDetailVo
				.setSettlementPeriodState(fsDetail.getSettlementPeriodState());
		fsDetailVo.setDeleteFlag(fsDetail.getDeleteFlag());
		return fsDetailVo;
	}

	/**
	 * @methodName： getFsDetail
	 * @Description: 运费结算明细单实体表转虚拟表
	 * @param FreightSettlementDetailVo
	 * @return FreightSettlementDetail
	 * @author: gaoyaxiong
	 * @date: 2013-5-27 下午13:22:03
	 */
	public FreightSettlementDetail getFsDetail(
			FreightSettlementDetailVo fsDetailVo) {
		FreightSettlementDetail fsDetail = new FreightSettlementDetail();
		fsDetail.setId(fsDetailVo.getId());
		fsDetail.setStatementNo(fsDetailVo.getStatementNo());
		fsDetail.setExpressNo(fsDetailVo.getExpressNo());
		fsDetail.setOrderNo(fsDetailVo.getOrderNo());
		fsDetail.setSendAddress(fsDetailVo.getSendAddress());
		fsDetail.setProductWeight(fsDetailVo.getProductWeight());
		fsDetail.setLogisticsExpenses(fsDetailVo.getLogisticsExpenses());
		fsDetail.setSendDate(fsDetailVo.getSendDate());
		fsDetail.setSettlementPeriodState(fsDetailVo.getSettlementPeriodState());
		fsDetail.setDeleteFlag(fsDetailVo.getDeleteFlag());
		return fsDetail;
	}

	/**
	 * @methodName： getNewFreightSettlement
	 * @Description: 新增运费结算单
	 * @param FreightSettlementVo
	 * @return FreightSettlement
	 * @author: gaoyaxiong
	 * @date: 2013-5-28 下午16:02:03
	 */
	public FreightSettlement getNewFreightSettlement(FreightSettlementVo fsVo) {
		FreightSettlement fs = new FreightSettlement();
		String no = "LC"
				+ DateUtil.formatDateByFormat(new Date(),
						DateUtil.NOCHAR_PATTERN)
				+ RandomUtil.getRandomNumberStr(5);
		fs.setStatementNo(no);
		fs.setLogisticsNo(fsVo.getLogisticsNo());
		fs.setLogisticsName(fsVo.getLogisticsName());
		fs.setStartDate(fsVo.getStartDate());
		fs.setEndDate(fsVo.getEndDate());
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		fs.setCreateTime(dateFormat.format(new Date()));
		fs.setCheckState(SZSCMConstant.FIN_AU_STA_O);
		fs.setStatementState(SZSCMConstant.FIN_ST_STA_O);
		fs.setDeleteFlag(SZSCMConstant.DELETE_FLAG_NO);
		return fs;
	}
}
